package com.wb3.meta.api.core.controller;

import com.wb3.meta.api.core.service.WinningRecordService;
import com.wb3.meta.api.core.vo.ReqWinningRecordVo;
import com.wb3.meta.common.annotation.NoPermission;
import com.wb3.meta.common.annotation.RequireAuth;
import com.wb3.meta.common.plugin.BaseResultController;
import com.wb3.meta.common.pojo.ResultT;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "抽奖-记录接口")
@RequestMapping("base/winning/record/")
public class WinningRecordController extends BaseResultController<ReqWinningRecordVo> {

    @Autowired
    private WinningRecordService winningRecordService;
    /**
     * 列表接口
     *
     * @param reqWinningRecordVo
     */
    @Override
    @RequireAuth
    @ApiOperation("列表接口")
    @GetMapping("list")
    public ResultT list(ReqWinningRecordVo reqWinningRecordVo) {

        return winningRecordService.getModelMapPage(reqWinningRecordVo);
    }


    /**
     * 明细接口
     *
     * @param reqWinningRecordVo
     */
    @Override
    @RequireAuth
    @ApiOperation("详情接口")
    @GetMapping("detail")
    public ResultT detail(ReqWinningRecordVo reqWinningRecordVo) {
        return winningRecordService.getModelMapById(reqWinningRecordVo.getId());
    }

    /**
     * 新增or更新接口
     *
     * @param reqWinningRecordVo
     */
    @NoPermission
    @Override
    @ApiOperation("更新接口")
    @PostMapping("update")
    public ResultT saveOrUpdate(@RequestBody ReqWinningRecordVo reqWinningRecordVo) {
        return winningRecordService.saveOrUpdate(reqWinningRecordVo);
    }

    /**
     * 删除接口
     *
     * @param reqWinningRecordVo
     */
    @NoPermission
    @Override
    @ApiOperation("删除接口")
    @PostMapping("delete")
    public ResultT delete(@RequestBody ReqWinningRecordVo reqWinningRecordVo) {
        return winningRecordService.delete(reqWinningRecordVo);
    }
}
